"""
@Project ：cs 
@File    ：hash.py
@Author  ：JianH
@Date    ：2022/6/20 11:11 
"""
import asyncio
import base64
import hashlib


async def hash_(data):
    _base64 = str(base64.b64encode(data.encode('utf-8')), encoding="utf-8")
    _base16 = str(base64.b16encode(data.encode('utf-8')), encoding="utf-8")
    _base32 = str(base64.b32encode(data.encode('utf-8')), encoding="utf-8")

    _md5 = hashlib.md5(data.encode()).hexdigest()

    sha1 = hashlib.sha1(data.encode()).hexdigest()
    sha224 = hashlib.sha224(data.encode()).hexdigest()
    sha256 = hashlib.sha256(data.encode()).hexdigest()
    sha384 = hashlib.sha384(data.encode()).hexdigest()
    sha512 = hashlib.sha512(data.encode()).hexdigest()
    sha3_224 = hashlib.sha3_224(data.encode()).hexdigest()
    sha3_256 = hashlib.sha3_256(data.encode()).hexdigest()
    sha3_384 = hashlib.sha3_384(data.encode()).hexdigest()
    sha3_512 = hashlib.sha3_512(data.encode()).hexdigest()

    blake2b = hashlib.blake2b(data.encode()).hexdigest()
    blake2s = hashlib.blake2s(data.encode()).hexdigest()

    return {"base16": _base16, "base32": _base32, "base64": _base64, "md5": _md5,
            "sha1": sha1, "sha256": sha256, "sha384": sha384, "sha512": sha512,
            "sha224": sha224, "blake2b": blake2b, "sha3_224": sha3_224, "sha3_256": sha3_256,
            "sha3_384": sha3_384, "sha3_512": sha3_512, "blake2s": blake2s}


if __name__ == '__main__':
    c = ''
    task = asyncio.ensure_future(hash_(c))
    loop = asyncio.get_event_loop()
    c = loop.run_until_complete(task)
    for g, v in c.items():
        print(f'{g} : {len(v)} : {v}')
